const mongoose = require("mongoose");
// mongoose.connect("mongodb://localhost/test",{useMongoClient:true});
mongoose.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
mongoose.Promise = Promise;

const Regmes = mongoose.model("Regmes",{
  loginname:{
    type:String,
    match:[/^[\u4e00-\u9fa5A-Za-z0-9-_]{3,10}$/,"用户名只能使用中英文，数字，下划线，减号，长度在3~10之间。"]
  },
  password:{
    type:String,
    match:[/^[a-zA-Z]\w{5,11}$/,"密码应以字母开头，只能包含字符、数字和下划线，长度在6-12之间。"]
  },
  admin:{
    type:Boolean,
    default:false
  }
});

module.exports = Regmes;
